/**
 * @param {string} s
 * @return {string}
 */
var makeSmallestPalindrome = function (s) {
  let res = ''
  let len = s.length
  let low, high
  if(len%2==0){
    high = len/2
    low = len/2-1
  }else{
    high =Math.ceil(len/2)
    low =Math.floor(len/2)-1
    res+=s[Math.floor(len/2)]
  }
  while(low>=0){
    if(s[low]!=s[high]){
     if(s[low]<=s[high]){
      res=s[low]+res+s[low]
     }else{
      res=s[high]+res+s[high]
     }
    }else{
      res= s[low]+res+s[high]
    }
    low--
    high++
  }
  return res

};

makeSmallestPalindrome('egcfe')